package cn.lzj.ymcc.feign;

import cn.lzj.ymcc.doc.CourseDoc;
import cn.lzj.ymcc.result.JSONResult;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

@Component
public class CourseESFeignClientFallbackFactory implements FallbackFactory<CourseESFeignClient> {
    @Override
    public CourseESFeignClient create(Throwable throwable) {
        return new CourseESFeignClient() {

            @Override
            public JSONResult savees(CourseDoc courseDoc) {
                throwable.printStackTrace();
                return JSONResult.error("上架失败！！已降级");
            }

            @Override
            public JSONResult offLineCourse(Long id) {
                throwable.printStackTrace();
                return JSONResult.error("下架失败！！已降级");
            }
        };
    }
}
